package com.bzkj.web.controller.ncc;

import com.bzkj.basicinfo.service.ncc.NccBasicSkuService;
import com.bzkj.common.core.controller.BaseController;
import com.bzkj.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/ncc/basic/sku")
public class NccBasicSkuController extends BaseController {

    @Autowired
    private NccBasicSkuService nccBasicSkuService;

    /**
     * NCC商品信息根据code查询
     *
     * @param code
     * @return
     */
    @GetMapping("/info/{code}")
    @PreAuthorize("@ss.hasPermi('ncc:Info:query')")
    public AjaxResult getNccInfoByCode(@PathVariable("code") String code) {
        return success(nccBasicSkuService.selectNccInfoByCode(code));
    }

    /**
     * 用来在新增二次细分表的时候展示ncc_basic_sku_type下的：ncc_stu_name和pk_marbasclass
     * @return
     */
    @GetMapping("/info/all")
    @PreAuthorize("@ss.hasPermi('ncc:InfoAll:query')")
    public AjaxResult getNccInfoAll() {
        return AjaxResult.success(nccBasicSkuService.getNccInfoAll());
    }

    /**
     * NCC商品分类根据code查询
     *
     * @param code
     * @return
     */
    @GetMapping("/type/{code}")
    @PreAuthorize("@ss.hasPermi('ncc:Type:query')")
    public AjaxResult getNccTypeByCode(@PathVariable("code") String code) {
        return success(nccBasicSkuService.selectNccTypeByCode(code));
    }

    /**
     * NCC商品信息定时任务
     */
    @GetMapping({"/nccBasicSkuInfoJob", "/nccBasicSkuInfoJob/{all}"})
    @PreAuthorize("@ss.hasPermi('ncc:Info:Job')")
    public void nccBasicSkuInfoJob(@PathVariable(required = false) String all) {
        nccBasicSkuService.updateNccBasicSkuInfoJob(all);
    }

    /**
     * NCC商品分类定时任务
     */
    @GetMapping({"/nccBasicSkuTypeJob", "/nccBasicSkuTypeJob/{all}"})
    @PreAuthorize("@ss.hasPermi('ncc:Type:Job')")
    public void nccBasicSkuTypeJob(@PathVariable(required = false) String all) {
        nccBasicSkuService.updateNccBasicSkuTypeJob(all);
    }

    /**
     * NCC物料单位定时任务
     */
    @GetMapping({"/nccBasicdepartmentJob", "/nccBasicdepartmentJob/{all}"})
    @PreAuthorize("@ss.hasPermi('ncc:Department:Job')")
    public void nccBasicDepartmentJob(@PathVariable(required = false) String all) {
        nccBasicSkuService.updateNccBasicDepartmentJob(all);
    }

    /**
     * NCC物料换算系数定时任务
     */
    @GetMapping({"/nccBasicReducedUnitJob", "/nccBasicReducedUnitJob/{all}"})
    @PreAuthorize("@ss.hasPermi('ncc:ReducedUnit:Job')")
    public void nccBasicReducedUnitJob(@PathVariable(required = false) String all) {
        nccBasicSkuService.updateNccBasicReducedUnitJob(all);
    }
}
